package com.bw.demo_mvp.base;

import android.view.View;

import java.lang.ref.WeakReference;

import io.reactivex.disposables.CompositeDisposable;

/**
 * @Author : ZhouZiYao
 * @Time : On 2023/11/16 20:17
 * @Description :
 */
public class Basepres <V>{
    private WeakReference<V> weakReference;
    protected CompositeDisposable compositeDisposable=new CompositeDisposable();
    public void aa(V view){
        weakReference=new WeakReference<V>(view);
    }
    public void bb(){
        if(weakReference!=null){
            weakReference.clear();
            weakReference=null;
        }
        if(compositeDisposable!=null){
            compositeDisposable.clear();
            compositeDisposable=null;
        }
    }
    public boolean cc(){
        return weakReference!=null&&weakReference.get()!=null;
    }
    public V dd(){
        return weakReference!=null&&weakReference.get()!=null?weakReference.get():null;
    }
}
